  getPage(1);
//翻页
function getPage(pn){
  var dataCount= "<%=totalnum%>";//总数据条数
  var pageSize=5;//每页显示条数
  var pageCount= Math.ceil(dataCount / pageSize);//总页数
  if(pn==0||pn>pageCount){
    return;
  }
  var ul=$(".small-thumb");
  ul.empty();
  //console.log(pageCount+"..."+pn)
  paintPage(pageCount,pn);   //绘制页码
  var startPage = pageSize * (pn - 1);

  if (pageCount == 1) {     // 当只有一页时 
    for (var j = 0; j < dataCount; j++) {  
      var e='<li><a href="s.getShopurl()"><img class="shop" src="'+s.getImgurl()+'"'
			+'alt="" width=150 height=120 border=0/> </a>'
			+'<div class="entry"><h6>'+
					+'<a href="'+s.getShopurl()+'">'+s.getShopname() +'</a>'
				+'</h6>'
				+'<div class="shopplaceL">'
					+'<span>口味</span><b>'+s.getTaste()+'分</b> <span>环境</span><b>'+s.getEnvironment()+'分</b> <span>服务</span><b>'+s.getService()+'分</b>'

				+'</div>'
				+'<div class="shopinfo">'
					+'<a class="post-date"><span>人均消费</span> | <b>'+s.getPrice()+'元</b>     &nbsp&nbsp<span>评价人数</span> | <b>'+s.getComment()+'人</b></a>'
				+'</div>'
				+'<div class="shopplaceR">'
					+'<a class="post-date"><span>地理位置</span> | '+s.getDistrict()+'</a>'
				+'</div>'
				+'<div class="shop">'
					+'<a class="post-date"><span>详细地址</span> | '+s.getAdress()+'</a>'
				+'</div>'
			+'</div>' 
			+'<div class="clear"></div></li>';
      ul.append(e);    
    }
  }else {      // 当超过一页时 
    var e=""; 
    var endPage = pn<pageCount?pageSize * pn:dataCount;
    for (var j = startPage; j < endPage; j++) {  
      var e='<li><a href="s.getShopurl()"><img class="shop" src="'+s.getImgurl()+'"'
		+'alt="" width=150 height=120 border=0/> </a>'
		+'<div class="entry"><h6>'+
				+'<a href="'+s.getShopurl()+'">'+s.getShopname() +'</a>'
			+'</h6>'
			+'<div class="shopplaceL">'
				+'<span>口味</span><b>'+s.getTaste()+'分</b> <span>环境</span><b>'+s.getEnvironment()+'分</b> <span>服务</span><b>'+s.getService()+'分</b>'

			+'</div>'
			+'<div class="shopinfo">'
				+'<a class="post-date"><span>人均消费</span> | <b>'+s.getPrice()+'元</b>     &nbsp&nbsp<span>评价人数</span> | <b>'+s.getComment()+'人</b></a>'
			+'</div>'
			+'<div class="shopplaceR">'
				+'<a class="post-date"><span>地理位置</span> | '+s.getDistrict()+'</a>'
			+'</div>'
			+'<div class="shop">'
				+'<a class="post-date"><span>详细地址</span> | '+s.getAdress()+'</a>'
			+'</div>'
		+'</div>' 
		+'<div class="clear"></div></li>';
      ul.append(e);
    }
  }
}

//绘制页码
  function paintPage(number,currNum)  //number 总页数,currNum 当前页  
  {
    var pageUl=$(".fenye");
    pageUl.empty();
    var ulDetail="";

    if(number==1){
     ulDetail= "<li class=\"prev\"><a href=\"javascript:void(0)\">上一页</a></li>"+
     "<li class=\"numb choose\"><a href=\"javascript:getPage(1)\">1</a></li>"+
     "<li class=\"next\"><a href=\"javascript:void(0)\">下一页</a></li>";
   }else if(number==2){
     ulDetail= "<li class=\"prev\"><a href=\"javascript:getPage(1)\">上一页</a></li>"+
     "<li class=\"numb"+choosele(currNum,1)+"\"><a href=\"javascript:getPage(1)\">1</a></li>"+
     "<li class=\"numb"+choosele(currNum,2)+"\"><a href=\"javascript:getPage(2)\">2</a></li>"+
     "<li class=\"next\"><a href=\"javascript:getPage(2)\">下一页</a></li>";
   }else if(number==3){
     ulDetail= "<li class=\"prev\"><a href=\"javascript:getPage("+parseInt(currNum-1)+")\">上一页</a></li>"+
     "<li class=\"numb"+choosele(currNum,1)+"\"><a href=\"javascript:getPage(1)\">1</a></li>"+
     "<li class=\"numb"+choosele(currNum,2)+"\"><a href=\"javascript:getPage(2)\">2</a></li>"+
     "<li class=\"numb"+choosele(currNum,3)+"\"><a href=\"javascript:getPage(3)\">3</a></li>"+
     "<li class=\"next\"><a href=\"javascript:getPage("+parseInt(currNum+1)+")\">下一页</a></li>";
   }else if(number==currNum&&currNum>3){
     ulDetail= "<li class=\"prev\"><a href=\"javascript:getPage("+parseInt(currNum-1)+")\">上一页</a></li>"+
     "<li class=\"numb\"><a href=\"javascript:getPage("+parseInt(currNum-2)+")\">"+parseInt(currNum-2)+"</a></li>"+
     "<li class=\"numb\"><a href=\"javascript:getPage("+parseInt(currNum-1)+")\">"+parseInt(currNum-1)+"</a></li>"+
     "<li class=\"numb choose\"><a href=\"javascript:getPage("+currNum+")\">"+currNum+"</a></li>"+
     "<li class=\"next\"><a href=\"javascript:getPage("+currNum+")\">下一页</a></li>";
   }else if(currNum==1&&number>3){
     ulDetail= "<li class=\"prev\"><a href=\"javascript:void(0)\">上一页</a></li>"+
     "<li class=\"numb choose\"><a href=\"javascript:void(0)\">1</a></li>"+
     "<li class=\"numb\"><a href=\"javascript:getPage(2)\">2</a></li>"+
     "<li class=\"numb\"><a href=\"javascript:getPage(3)\">3</a></li>"+
     "<li class=\"next\"><a href=\"javascript:getPage(2)\">下一页</a></li>";
   }else{
     ulDetail= "<li class=\"prev\"><a href=\"javascript:getPage("+parseInt(currNum-1)+")\">上一页</a></li>"+
     "<li class=\"numb\"><a href=\"javascript:getPage("+parseInt(currNum-1)+")\">"+parseInt(currNum-1)+"</a></li>"+
     "<li class=\"numb choose\"><a href=\"javascript:getPage("+currNum+")\">"+currNum+"</a></li>"+
     "<li class=\"numb\"><a href=\"javascript:getPage("+parseInt(currNum+1)+")\">"+parseInt(currNum+1)+"</a></li>"+
     "<li class=\"next\"><a href=\"javascript:getPage("+parseInt(currNum+1)+")\">下一页</a></li>";
   }

   $(".fenye").append(ulDetail);

 }

 function choosele(num,cur){
  if(num==cur){
    return " choose";
  }else{
    return "";
  }
}